package com.hyacinth.utils.serialize;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.nustaq.serialization.FSTConfiguration;

/**
 * @author zhangfb
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class FSTUtils {

    private static final FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

    public static <T> byte[] serializer(T t){
        return conf.asByteArray(t);
    }

    @SuppressWarnings("unchecked")
    public static <T> T deserializer(byte[] bytes,Class<T> c) {
        return  (T)conf.asObject(bytes);
    }
}
